package com.lagou.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lagou.pojo.Article;
import com.lagou.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @RequestMapping("/getAllArticle")
    public String getAllArticle(Model model,@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum) {
        System.out.println("进入服务");
        PageHelper.startPage(pageNum,2);
        List<Article> list = articleService.getAllArticle();
        PageInfo<Article> pageInfo = new PageInfo<>(list);
        model.addAttribute("pageInfo",pageInfo);
        return "client/index";
    }
}
